ARROW-11788: [Java] Fix appending empty delta vectors#9581
Closed
nbruno wants to merge 2 commits into
Closed
Conversation
liyafan82
reviewed
Feb 26, 2021
| try (IntVector target = new IntVector("", allocator); | ||
| IntVector delta = new IntVector("", allocator)) { | ||
|
|
||
| target.allocateNew(10); |
Contributor
There was a problem hiding this comment.
This is not needed, as ValueVectorDataPopulator.setVector will do the allocation.
Contributor
Author
There was a problem hiding this comment.
I removed all explicit calls for allocation if the utility method performs the allocation.
liyafan82
reviewed
Feb 26, 2021
| assertEquals(10, target.getValueCount()); | ||
|
|
||
| try (IntVector expected = new IntVector("expected", allocator)) { | ||
| expected.allocateNew(); |
liyafan82
reviewed
Feb 26, 2021
| try (VarCharVector target = new VarCharVector("", allocator); | ||
| VarCharVector delta = new VarCharVector("", allocator)) { | ||
|
|
||
| target.allocateNew(5, 10); |
Contributor
There was a problem hiding this comment.
This is not needed either, as ValueVectorDataPopulator.setVector calls the getSafe method.
Contributor
|
@nbruno Thanks for the PR. Merging. |
pribor
pushed a commit
to GlobalWebIndex/arrow
that referenced
this pull request
Oct 24, 2025
This PR fixes a bug where appending an empty list vector fails with a `NullPointerException`. Instead of attempting to process the delta vector, we just return early with the unmodified target vector, since there is nothing to append to the target vector from the delta vector. In addition, it fixes cases where appending an empty delta vector would've caused the same NPE, or where it'd be an optimization to not attempt processing an empty delta vector. Unit tests are added for all supported `VectorAppender` vector types. Closes apache#9581 from nbruno/ARROW-11788 Authored-by: Nick Bruno <nbruno@users.noreply.github.com> Signed-off-by: liyafan82 <fan_li_ya@foxmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug where appending an empty list vector fails with a
NullPointerException. Instead of attempting to process the delta vector, we just return early with the unmodified target vector, since there is nothing to append to the target vector from the delta vector. In addition, it fixes cases where appending an empty delta vector would've caused the same NPE, or where it'd be an optimization to not attempt processing an empty delta vector. Unit tests are added for all supportedVectorAppendervector types.